﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LoginViewModel.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the <seealso cref="LoginViewModel" /> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Client.Desktop.ViewModel
{
    using System.Reflection;
    using System.Windows.Input;
    using Hisaab.Client.Common.BaseClasses;
    using Hisaab.Client.Desktop.Commands;
    using Hisaab.Client.Desktop.Properties;
    using Hisaab.Client.Model;

    /// <summary>
    /// Defines the <seealso cref="LoginViewModel"/> type.
    /// </summary>
    public class LoginViewModel : ViewModelBase
    {
        /// <summary>
        /// Member variable _appName
        /// </summary>
        private string _appName;

        /// <summary>
        /// Member variable _message
        /// </summary>
        private string _message;

        /// <summary>
        /// Member variable _versionString
        /// </summary>
        private string _versionString;

        /// <summary>
        /// Member variable _copyright
        /// </summary>
        private string _copyright;

        /// <summary>
        /// Member variable _loginCommand
        /// </summary>
        private LoginCommand _loginCommand;

        /// <summary>
        /// Member variable _exitCommand
        /// </summary>
        private ICommand _exitCommand;

        /// <summary>
        /// Gets the login command.
        /// </summary>
        /// <value>
        /// The login command.
        /// </value>
        public ICommand LoginCommand
        {
            get
            {
                return _loginCommand ?? (_loginCommand = new LoginCommand(this));
            }
        }

        /// <summary>
        /// Gets the cancel command.
        /// </summary>
        /// <value>
        /// The cancel command.
        /// </value>
        public ICommand CancelCommand
        {
            get
            {
                return _exitCommand ?? (_exitCommand = new ExitCommand());
            }
        }

        /// <summary>
        /// Gets or sets the user.
        /// </summary>
        /// <value>
        /// The user.
        /// </value>
        public User User { get; set; }

        /// <summary>
        /// Gets or sets the app title.
        /// </summary>
        /// <value>
        /// The app title.
        /// </value>
        public string AppName
        {
            get
            {
                return _appName ?? (_appName = Resources.ApplicationName);
            }

            set
            {
                _appName = value;
                RaisePropertyChangedEvent("AppName");
            }
        }

        /// <summary>
        /// Gets or sets the message.
        /// </summary>
        /// <value>
        /// The message.
        /// </value>
        public string Message
        {
            get
            {
                return _message;
            }

            set
            {
                _message = value;
                RaisePropertyChangedEvent("Message");
            }
        }

        /// <summary>
        /// Gets or sets the version string.
        /// </summary>
        /// <value>
        /// The version string.
        /// </value>
        public string VersionString
        {
            get
            {
                return _versionString ?? (_versionString = Assembly.GetExecutingAssembly().GetName().Version.ToString());
            }

            set
            {
                _versionString = value;
                RaisePropertyChangedEvent("VersionString");
            }
        }

        /// <summary>
        /// Gets or sets the copyright.
        /// </summary>
        /// <value>
        /// The copyright.
        /// </value>
        public string Copyright
        {
            get
            {
                return _copyright ?? (_copyright = Resources.CopyRightString);
            }

            set
            {
                _copyright = value;
                RaisePropertyChangedEvent("Copyright");
            }
        }
    }
}